<% layout('/layouts/default.html', {title: '公共资料管理', libs: ['dataGrid']}){ %>
<div class="main-content">
	<div class="box box-main">
		<div class="box-header">
			<div class="box-title">
				<i class="fa icon-notebook"></i> ${text('公共资料管理')}
			</div>
			<div class="box-tools pull-right">
				<a href="#" class="btn btn-default" id="btnSearch" title="${text('查询')}"><i class="fa fa-filter"></i> ${text('查询')}</a>
				<a href="#" class="btn btn-default" id="btnRefreshTree" title="${text('刷新')}"><i class="fa fa-refresh"></i> ${text('刷新')}</a>
				<a href="#" class="btn btn-default" id="btnExpandTreeNode" title="${text('展开一级')}"><i class="fa fa-angle-double-down"></i> ${text('展开')}</a>
				<a href="#" class="btn btn-default" id="btnCollapseTreeNode" title="${text('折叠全部')}"><i class="fa fa-angle-double-up"></i> ${text('折叠')}</a>
				<% if(hasPermi('zx:common:material:tcommonMaterial:edit')){ %>
					<a href="${ctx}/zx/common/material/tcommonMaterial/form?objExplain=0" class="btn btn-default btnTool" title="${text('新增公共资料')}"><i class="fa fa-plus"></i> ${text('新增')}</a>
				<% } %>
			</div>
		</div>
		<div class="box-body">
			<#form:form id="searchForm" model="${tcommonMaterial}" action="${ctx}/zx/common/material/tcommonMaterial/listData" method="post" class="form-inline hide"
					data-page-no="${parameter.pageNo}" data-page-size="${parameter.pageSize}" data-order-by="${parameter.orderBy}">
				<div class="form-group">
					<label class="control-label">${text('数据名称')}：</label>
					<div class="control-inline">
						<#form:input path="objName" maxlength="255" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('图片')}：</label>
					<div class="control-inline">
						<#form:input path="objPicture" maxlength="500" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('数据类型')}：</label>
					<div class="control-inline">
						<#form:input path="objType" maxlength="10" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('status')}：</label>
					<div class="control-inline width-120">
						<#form:select path="status" dictType="sys_search_status" blankOption="true" class="form-control isQuick"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('备注做附件的保存路径')}：</label>
					<div class="control-inline">
						<#form:input path="remarks" maxlength="1555" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('数据说明')}：</label>
					<div class="control-inline">
						<#form:input path="objExplain" maxlength="10" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('答案')}：</label>
					<div class="control-inline">
						<#form:input path="objAnswer" maxlength="255" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<button type="submit" class="btn btn-primary btn-sm">${text('查询')}</button>
					<button type="reset" class="btn btn-default btn-sm">${text('重置')}</button>
				</div>
			</#form:form>
			<table id="dataGrid"></table>
		</div>
	</div>
</div>
<% } %>
<script>
// 初始化DataGrid对象
$('#dataGrid').dataGrid({
	searchForm: $("#searchForm"),
	columnModel: [
		{header:'${text("数据名称")}', name:'objName', index:'a.obj_name', width:250, align:"left", frozen:true, formatter: function(val, obj, row, act){
			var objExplain=row.objExplain;
			return '<a href="${ctx}/zx/common/material/tcommonMaterial/form?objExplain='+objExplain+'&id='+row.id+'" class="btnList" data-title="${text("编辑公共资料")}">'+(val||row.id)+'</a>';
		}},
		{header:'${text("数据说明")}', name:'objExplain', index:'a.obj_explain', width:150, align:"center", formatter: function(val, obj, row, act){
			return js.getDictLabel(${@DictUtils.getDictListJson('t_material_query')}, val, '${text("子类")}', true);
		}},
		{header:'${text("数据类型")}', name:'objType', index:'a.obj_type', width:150, align:"center", formatter: function(val, obj, row, act){
			return js.getDictLabel(${@DictUtils.getDictListJson('t_material_type')}, val, '${text("子类")}', true);
		}},
		{header:'${text("图片")}', hidden:true, name:'objPicture', index:'a.obj_picture', width:150, align:"left"},
		
		{header:'${text("排序号")}', name:'treeSort', index:'a.tree_sort', width:150, align:"center"},
		{header:'${text("update_date")}',hidden:true,  name:'updateDate', index:'a.update_date', width:150, align:"center"},
		{header:'${text("状态")}', name:'status', index:'a.status', width:150, align:"center", formatter: function(val, obj, row, act){
			return js.getDictLabel(${@DictUtils.getDictListJson('sys_search_status')}, val, '${text("未知")}', true);
		}},
		{header:'${text("备注做附件的保存路径")}',hidden:true,  name:'remarks', index:'a.remarks', width:150, align:"left"},
		
		{header:'${text("答案")}',hidden:true,  name:'objAnswer', index:'a.obj_answer', width:150, align:"left"},
		{header:'${text("操作")}', name:'actions', width:120, sortable:false, title:false, formatter: function(val, obj, row, act){
			var actions = [];
			var objExplain=row.objExplain;
			<% if(hasPermi('zx:common:material:tcommonMaterial:edit')){ %>
				actions.push('<a href="${ctx}/zx/common/material/tcommonMaterial/form?objExplain='+objExplain+'&id='+row.id+'" class="btnList" title="${text("编辑公共资料")}"><i class="fa fa-pencil"></i></a>&nbsp;');
				if (row.status == Global.STATUS_NORMAL){
					actions.push('<a href="${ctx}/zx/common/material/tcommonMaterial/disable?id='+row.id+'" class="btnList" title="${text("停用公共资料")}" data-confirm="${text("确认要停用该公共资料吗？")}"><i class="glyphicon glyphicon-ban-circle"></i></a>&nbsp;');
				} else if (row.status == Global.STATUS_DISABLE){
					actions.push('<a href="${ctx}/zx/common/material/tcommonMaterial/enable?id='+row.id+'" class="btnList" title="${text("启用公共资料")}" data-confirm="${text("确认要启用该公共资料吗？")}"><i class="glyphicon glyphicon-ok-circle"></i></a>&nbsp;');
				}
				actions.push('<a href="${ctx}/zx/common/material/tcommonMaterial/delete?id='+row.id+'" class="btnList" title="${text("删除公共资料")}" data-confirm="${text("确认要删除该公共资料及所有子公共资料吗？")}" data-deltreenode="'+row.id+'"><i class="fa fa-trash-o"></i></a>&nbsp;');
				
				if(objExplain==0){
					actions.push('<a href="${ctx}/zx/common/material/tcommonMaterial/form?objExplain=1&parentCode='+row.id+'" class="btnList" title="${text("新增下级公共资料")}"><i class="fa fa-plus-square"></i></a>&nbsp;');
				}
				
			<% } %>
			return actions.join('');
		}}
	],
	treeGrid: true,			// 启用树结构表格
	defaultExpandLevel: 0,	// 默认展开的层次
	expandNodeClearPostData: 'objName,objPicture,objType,remarks,objExplain,objAnswer,', // 展开节点清理请求参数数据（一般设置查询条件的字段属性，否则在查询后，不能展开子节点数据）
	// 加载成功后执行事件
	ajaxSuccess: function(data){
		
	}
});
</script>